﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using LCA.Community.DAL.Model;
using Microsoft.Practices.Unity;
using LCA.Community.DAL.Interfaces;

namespace LCA.Community.Web.Models
{
    public class UserViewModel : ISocialNetworkElement
    {
        public UserViewModel(User user)
        {
            User = user;
        }

        #region Properties
        public User User { get; set; }

        public Object Element
        {
            get
            {
                return User;
            }
        }

        public string Alias
        {
            get
            {
                return User.Alias;
            }
        }

        public List<PostViewModel> Posts
        {
            get
            {
                return PostViewModel.ConvertListPost(PostsRepository.GetPostByUser(User.RowKey));
            }
        }

        public List<User> Friends
        {
            get
            {
                return UsersRepository.GetUserFriends(User.RowKey);
            }
        }

        public List<Phrase> Phrases
        {
            get
            {
                return PhrasesRepository.GetPhrasesByUser(User.RowKey);
            }
        }

        public List<Message> Messages
        {
            get
            {
                return MessagesRepository.GetInbox(User.RowKey);
            }
        }

        public string ID
        {
            get
            {
                return User.ID;
            }
        }

        public List<Group> Groups
        {
            get
            {
                return GroupsRepository.GetGroupsByUser(User.RowKey);
            }
        }
        #endregion

        #region Dependencies
        [Dependency]
        public IPostsRepository PostsRepository { get; set; }
        [Dependency]
        public IUsersRepository UsersRepository { get; set; }
        [Dependency]
        public IPhrasesRepository PhrasesRepository { get; set; }
        [Dependency]
        public IMessagesRepository MessagesRepository { get; set; }
        [Dependency]
        public IGroupsRepository GroupsRepository { get; set; }
        #endregion
    }
}